#pragma once

#include <include/cef_urlrequest.h>
#include "CCefResourceHandler.h"

class CCefURLRequestClient : public CefURLRequestClient
{
public:
	CCefURLRequestClient() {}
	CCefURLRequestClient(CefRefPtr<CefFrame> _frame);
	
	// CefURLRequestClient methods
	virtual void OnRequestComplete(CefRefPtr<CefURLRequest> request) OVERRIDE;
	virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request, int64 current, int64 total) OVERRIDE {}
	virtual void OnDownloadProgress(CefRefPtr<CefURLRequest> request, int64 current, int64 total) OVERRIDE {}
	virtual void OnDownloadData(CefRefPtr<CefURLRequest> request, const void* data, size_t data_length) OVERRIDE;
	virtual bool GetAuthCredentials(bool isProxy, const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr<CefAuthCallback> callback) OVERRIDE { return true; }

public:
	CefRefPtr<CefResponse> _response;
	CefRefPtr<CCefResourceHandler> _resourceHandler;

	std::string _data;
	size_t _dataLength;

private:
	IMPLEMENT_REFCOUNTING(CCefURLRequestClient);
};
